From 8ac6c3bf18ce8cce36ae284dd8494bb7733f992a Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 7 Jan 2008 00:19:05 +0000 Subject: [PATCH] Uppercase all letters and strip spaces on Garmin routepoint names. --- garmin.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/garmin.c b/garmin.c index a06ca796a..a901c9bef 100644 --- a/garmin.c +++ b/garmin.c @@ -821,6 +821,7 @@ static void route_waypt_pr(const waypoint *wpt) { GPS_PWay rte = *cur_tx_routelist_entry; + char *s, *d; /* * As stupid as this is, libjeeps seems to want an empty @@ -844,7 +845,20 @@ route_waypt_pr(const waypoint *wpt) rte->alt_is_unknown = 1; rte->alt = 0; } - strncpy(rte->ident, wpt->shortname, sizeof(rte->ident)); + + // Garmin protocol spec says no spaces, no lowercase, etc. in a route. + // enforce that here, since jeeps doesn't. + // + // This was strncpy(rte->ident, wpt->shortname, sizeof(rte->ident)); + d = rte->ident; + for (s = wpt->shortname; *s; s++) { + int c = *s; + if (isalpha(c)) c = toupper(c); + if (strchr(MILITANT_VALID_WAYPT_CHARS, c)) { + *d++ = c; + } + } + rte->ident[sizeof(rte->ident)-1] = 0; if (wpt->description) { -- 2.30.2